// InitSkin.cpp: implementation of the CInitSkin class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "InitSkin.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

#include "Dib.h"

HHOOK CInitSkin::m_hPrevSkinHook = NULL;
CList<CWndSubclass*, CWndSubclass*> CInitSkin::m_lstWndSubclass;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CInitSkin::CInitSkin()
{

}

CInitSkin::~CInitSkin()
{
	m_lstWndSubclass.RemoveAll();
}

void CInitSkin::HookWindow(HWND hWnd)
{
	WindowType WndType = GetWindowType(hWnd);
	if (WndType == wtDlg || WndType == wtFrameWnd){
		CWndSubclass* pWndSubclass = new CMainWndSubclass;
		pWndSubclass->SubclassWindow(CWnd::FromHandle(hWnd));
		m_lstWndSubclass.AddHead(pWndSubclass);
	} else if (WndType == wtButton){
		CWndSubclass* pWndSubclass = new CButtonSubclass;
		pWndSubclass->SubclassWindow(CWnd::FromHandle(hWnd));
		m_lstWndSubclass.AddHead(pWndSubclass);
	} else if (WndType == wtEdit){
		CWndSubclass* pWndSubclass = new CEditSubclass;
		pWndSubclass->SubclassWindow(CWnd::FromHandle(hWnd));
		m_lstWndSubclass.AddHead(pWndSubclass);
	} else if (WndType == wtListCtrl){
		CWndSubclass* pWndSubclass = new CListCtrlSubclass;
		pWndSubclass->SubclassWindow(CWnd::FromHandle(hWnd));
		m_lstWndSubclass.AddHead(pWndSubclass);
	} else if (WndType == wtComboBox){
		CWndSubclass* pWndSubclass = new CComboBoxSubclass;
		pWndSubclass->SubclassWindow(CWnd::FromHandle(hWnd));
		m_lstWndSubclass.AddHead(pWndSubclass);
	} else if (WndType == wtStatic){
		CWndSubclass* pWndSubclass = new CStaticSubclass;
		pWndSubclass->SubclassWindow(CWnd::FromHandle(hWnd));
		m_lstWndSubclass.AddHead(pWndSubclass);
	} else if (WndType == wtTreeCtrl){
		CWndSubclass* pWndSubclass = new CTreeCtrlSubclass;
		pWndSubclass->SubclassWindow(CWnd::FromHandle(hWnd));
		m_lstWndSubclass.AddHead(pWndSubclass);
	} else if (WndType == wtMenuWnd){
		CWndSubclass* pWndSubclass = new CMenuWndSubclass;
		pWndSubclass->SubclassWindow(CWnd::FromHandle(hWnd));
		m_lstWndSubclass.AddHead(pWndSubclass);
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// Global hooks
LRESULT CALLBACK CInitSkin::SkinHookProc(int iCode, WPARAM wParam, LPARAM lParam)
{
	if ((((CWPSTRUCT *) lParam)->message == WM_CREATE) && (iCode >= 0)){
		HookWindow(((CWPSTRUCT *) lParam)->hwnd);
	}
	return CallNextHookEx(m_hPrevSkinHook, iCode, wParam, lParam);
}
////////////////////////////////////////////////////////////////////////////////////////////////////

BOOL CALLBACK CInitSkin::SkinEnumChildProc(HWND hwnd, LPARAM lParam)
{
	HookWindow(hwnd);
	EnumChildWindows(hwnd, SkinEnumChildProc, 0);
	return TRUE;
}

BOOL CALLBACK CInitSkin::SkinEnumThreadWndProc(HWND hwnd, LPARAM lParam)
{
	HookWindow(hwnd);
	EnumChildWindows(hwnd, SkinEnumChildProc, 0);
	return TRUE;
}

void CInitSkin::InstallSkin(CString strFileName)
{
	InitializeResource(strFileName);
	/*??Enume all the current window and subclass*/
	EnumThreadWindows(GetCurrentThreadId(), SkinEnumThreadWndProc, 0); 
	m_hPrevSkinHook = SetWindowsHookEx(WH_CALLWNDPROC, SkinHookProc, 0, GetCurrentThreadId());
}

void CInitSkin::UnInstallSkin()
{
	/*  //A error occurs, when tranverse the list
	CWndSubclass* pWndSubclass = m_lstWndSubclass.GetHead();
	while (pWndSubclass!= NULL){
		pWndSubclass->SubclassWindow(NULL);
		delete pWndSubclass;
		m_lstWndSubclass.RemoveHead();
		pWndSubclass = m_lstWndSubclass.GetHead();
	}
	UnhookWindowsHookEx(m_hPrevSkinHook);
	m_hPrevSkinHook = NULL;*/
	UnhookWindowsHookEx(m_hPrevSkinHook);
	m_hPrevSkinHook = NULL;
	POSITION pos = m_lstWndSubclass.GetHeadPosition();
	for (int i=0;i < m_lstWndSubclass.GetCount();i++){
		CWndSubclass* pWndSubclass = m_lstWndSubclass.GetNext(pos);
		if (pWndSubclass->IsSubclassed())
			pWndSubclass->UnSubclassWindow();
	}
	CWndSubclass* pWndSubclass;
	while (!m_lstWndSubclass.IsEmpty()){
		pWndSubclass = m_lstWndSubclass.GetHead();
		delete pWndSubclass;
		m_lstWndSubclass.RemoveHead();
	}

	FinalizeResource();
}

CInitSkin& CInitSkin::GetInitskin()
{
	static CInitSkin theInitSkin;
	return theInitSkin;
}

WindowType CInitSkin::GetWindowType(HWND hWnd)
{
	CString strWindowName;
	::GetClassName(hWnd,strWindowName.GetBufferSetLength(MAX_PATH), MAX_PATH);
	if (strWindowName == "#32770") 
		return wtDlg;
	else if ((strWindowName.Left(21) == "Afx:400000:b:10008:6:") || (strWindowName.Left(21) == "TFrmMain"))
		return wtFrameWnd;
	else if ((strWindowName == "Button") || (strWindowName.Left(21) == "TButton"))
	{
		if ((((CButton*)(CWnd::FromHandle(hWnd)))->GetButtonStyle() == BS_PUSHBUTTON)
			|| (((CButton*)(CWnd::FromHandle(hWnd)))->GetButtonStyle() == BS_DEFPUSHBUTTON))
			return wtButton;
	}
	else if ((strWindowName == "Edit") || (strWindowName.Left(21) == "TEdit"))
	{
		LONG dwStyle = ::GetWindowLong(hWnd, GWL_STYLE);
		if  (dwStyle != 0x50000300)
			return wtEdit;
	}
	else if ((strWindowName == "SysListView32") || (strWindowName.Left(21) == "TListView"))
	{	
		return wtListCtrl;
	}
	else if ((strWindowName == "ComboBox") || (strWindowName.Left(21) == "TComboBox"))
	{
		return wtComboBox;
	}
	else if (strWindowName == "Static")
	{
		return wtStatic;
	}
	else if ((strWindowName == "SysTreeView32") || (strWindowName == "TTreeView"))
	{
		return wtTreeCtrl;
	}
	else if (strWindowName == "#32768")
	{
		return wtMenuWnd;
	}
	return wtUnknown;
}

BOOL CInitSkin::InitializeResource(CString strFileName)
{
	m_skinResMgr.LoadFromFile(strFileName);
	CDib* pDib = new CDib();
	CSkinResDes SkinResDes;
	CClientDC dc(AfxGetMainWnd());
/*MainWnd*/
	/*Caption Bitmaps*/
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "Caption_Left_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemLeftCaption = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "Caption_Middle_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemMiddleCaption = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "Caption_Right_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemRightCaption = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "Min_Nor_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemMinCaption = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "Max_Nor_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemMaxCaption = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "Exit_Nor_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemExitCaption = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	/*Top Edge Bitmaps*/
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "TopEdge_Left_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemLeftTopEdge = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "TopEdge_Middle_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemMiddleTopEdge = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "TopEdge_Right_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemRightTopEdge= pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	/*Bottom Edge Bitmaps*/
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "BottomEdge_Left_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemLeftBottomEdge = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "BottomEdge_Middle_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemMiddleBottomEdge = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "BottomEdge_Right_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemRightBottomEdge= pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	/*Left Edge Bitmaps*/
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "LeftEdge_Top_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemTopLeftEdge = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "LeftEdge_Middle_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemMiddleLeftEdge = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "LeftEdge_Bottom_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemBottomLeftEdge= pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	/*Right Edge Bitmaps*/
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "RightEdge_Top_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemTopRightEdge = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "RightEdge_Middle_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemMiddleRightEdge = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "RightEdge_Bottom_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CMainWndSubclass::m_hMemBottomRightEdge= pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	/*Background Color*/
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "Caption_BKColor");	
	CMainWndSubclass::m_crBackCaption = *((int*)SkinResDes.m_pStart);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "TopEdge_BKColor");	
	CMainWndSubclass::m_crBackTopEdge = *((int*)SkinResDes.m_pStart);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "BottomEdge_BKColor");	
	CMainWndSubclass::m_crBackBottomEdge = *((int*)SkinResDes.m_pStart);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "LeftEdge_BKColor");	
	CMainWndSubclass::m_crBackLeftEdge = *((int*)SkinResDes.m_pStart);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "RightEdge_BKColor");	
	CMainWndSubclass::m_crBackRightEdge = *((int*)SkinResDes.m_pStart);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	/*Width or Height*/
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "Caption_Height");	
	CMainWndSubclass::m_nCaption = *((int*)SkinResDes.m_pStart);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "TopEdge_Pixels_Num");	
	CMainWndSubclass::m_nTop = *((int*)SkinResDes.m_pStart);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "BottomEdge_Pixels_Num");	
	CMainWndSubclass::m_nBottom = *((int*)SkinResDes.m_pStart);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "LeftEdge_Pixels_Num");	
	CMainWndSubclass::m_nLeft = *((int*)SkinResDes.m_pStart);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "RightEdge_Pixels_Num");	
	CMainWndSubclass::m_nRight = *((int*)SkinResDes.m_pStart);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	/*Rects*/
	CRect rc;
	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "Min_Rect");	
	rc.left = *((int*)(SkinResDes.m_pStart));
	rc.top = *((int*)(SkinResDes.m_pStart + 4));
	rc.right = *((int*)(SkinResDes.m_pStart)) + *((int*)(SkinResDes.m_pStart + 4*2));
	rc.bottom = *((int*)(SkinResDes.m_pStart + 4)) + *((int*)(SkinResDes.m_pStart + 4*3));
	CMainWndSubclass::m_rcMin = rc;
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "Max_Rect");	
	rc.left = *((int*)(SkinResDes.m_pStart));
	rc.top = *((int*)(SkinResDes.m_pStart + 4));
	rc.right = *((int*)(SkinResDes.m_pStart)) + *((int*)(SkinResDes.m_pStart + 4*2));
	rc.bottom = *((int*)(SkinResDes.m_pStart + 4)) + *((int*)(SkinResDes.m_pStart + 4*3));
	CMainWndSubclass::m_rcMax = rc;
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "Exit_Rect");	
	rc.left = *((int*)(SkinResDes.m_pStart));
	rc.top = *((int*)(SkinResDes.m_pStart + 4));
	rc.right = *((int*)(SkinResDes.m_pStart)) + *((int*)(SkinResDes.m_pStart + 4*2));
	rc.bottom = *((int*)(SkinResDes.m_pStart + 4)) + *((int*)(SkinResDes.m_pStart + 4*3));
	CMainWndSubclass::m_rcExit = rc;
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

	SkinResDes = m_skinResMgr.GetSkinRes("MainWnd", "Icon_Rect");	
	rc.left = *((int*)(SkinResDes.m_pStart));
	rc.top = *((int*)(SkinResDes.m_pStart + 4));
	rc.right = *((int*)(SkinResDes.m_pStart)) + *((int*)(SkinResDes.m_pStart + 4*2));
	rc.bottom = *((int*)(SkinResDes.m_pStart + 4)) + *((int*)(SkinResDes.m_pStart + 4*3));
	CMainWndSubclass::m_rcIcon = rc;
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);

/*Button*/
	SkinResDes = m_skinResMgr.GetSkinRes("Button", "Button_Normal_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CButtonSubclass::m_hNormalBmp = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("Button", "Button_Focus_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CButtonSubclass::m_hHoverBmp = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("Button", "Button_Pressed_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CButtonSubclass::m_hTrackBmp = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	SkinResDes = m_skinResMgr.GetSkinRes("Button", "Button_Disable_Bitmap");	
	pDib->LoadFromMem((const char*)SkinResDes.m_pStart, SkinResDes.m_nLength);
	CButtonSubclass::m_hDisableBmp = pDib->ToDDB(&dc);
	m_skinResMgr.DeleteSkinResData(SkinResDes.m_pStart);
	
	delete pDib;
	return TRUE;
}


BOOL CInitSkin::FinalizeResource()
{
	m_skinResMgr.CloseSkinFile();
/*MainWnd*/
	/*Caption Bitmaps*/
	DeleteObject(CMainWndSubclass::m_hMemLeftCaption);
	DeleteObject(CMainWndSubclass::m_hMemMiddleCaption);
	DeleteObject(CMainWndSubclass::m_hMemRightCaption);
	DeleteObject(CMainWndSubclass::m_hMemMinCaption);
	DeleteObject(CMainWndSubclass::m_hMemMaxCaption);
	DeleteObject(CMainWndSubclass::m_hMemExitCaption);
	/*Top Edge Bitmaps*/
	DeleteObject(CMainWndSubclass::m_hMemLeftTopEdge);
	DeleteObject(CMainWndSubclass::m_hMemMiddleTopEdge);
	DeleteObject(CMainWndSubclass::m_hMemRightTopEdge);
	/*Bottom Edge Bitmaps*/
	DeleteObject(CMainWndSubclass::m_hMemLeftBottomEdge);
	DeleteObject(CMainWndSubclass::m_hMemMiddleBottomEdge);
	DeleteObject(CMainWndSubclass::m_hMemRightBottomEdge);
	/*Left Edge Bitmaps*/
	DeleteObject(CMainWndSubclass::m_hMemTopLeftEdge);
	DeleteObject(CMainWndSubclass::m_hMemMiddleLeftEdge);
	DeleteObject(CMainWndSubclass::m_hMemBottomLeftEdge);
	/*Right Edge Bitmaps*/
	DeleteObject(CMainWndSubclass::m_hMemTopRightEdge);
	DeleteObject(CMainWndSubclass::m_hMemMiddleRightEdge);
	DeleteObject(CMainWndSubclass::m_hMemBottomRightEdge);

	CMainWndSubclass::m_rcExit = CRect(CPoint(3,0),CSize(20,20)); 
	CMainWndSubclass::m_rcMax= CRect(CPoint(24,0),CSize(20,20));
	CMainWndSubclass::m_rcMin = CRect(CPoint(46,0),CSize(20,20));
	CMainWndSubclass::m_rcIcon = CRect(CPoint(0,0), CSize(16,16));
	CMainWndSubclass::m_crBackCaption = RGB(0,0,0);;
	CMainWndSubclass::m_crBackTopEdge = RGB(0,0,0);;
	CMainWndSubclass::m_crBackBottomEdge = RGB(0,0,0);;
	CMainWndSubclass::m_crBackLeftEdge = RGB(0,0,0);;
	CMainWndSubclass::m_crBackRightEdge = RGB(0,0,0);;
	CMainWndSubclass::m_nLeft = 5;
	CMainWndSubclass::m_nTop = 5;
	CMainWndSubclass::m_nRight = 5;
	CMainWndSubclass::m_nBottom = 5;
	CMainWndSubclass::m_nCaption = 20;

/*Button*/
	DeleteObject(CButtonSubclass::m_hNormalBmp);
	DeleteObject(CButtonSubclass::m_hHoverBmp);
	DeleteObject(CButtonSubclass::m_hTrackBmp);
	DeleteObject(CButtonSubclass::m_hDisableBmp);
	return TRUE;
}